package com.example.uilearning;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.TextView;

public class ActivityForResult extends Activity {

	private EditText editText;

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if(requestCode==0&&resultCode==0){
			//取出Intent里的Extras数据
			editText.setText(data.getStringExtra("city"));
		}
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_activityforresult);
		editText = (EditText) findViewById(R.id.cityEdit);
	    editText.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				//创建需要对应于目标Activity的Intent
				Intent intent=new Intent(ActivityForResult.this,SelectCityActivity.class);
				startActivityForResult(intent, 0);
			}
		});
	}

}
